package com.varian.system.client;

import com.varian.service.remote.SysBizExceptionRemote;
import com.varian.system.service.ISysBizExceptionService;
import com.varian.tool.contant.VarianConstant;
import com.varian.tool.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ben
 * @since 2024/9/25
 */
@PermitAll
@RequiredArgsConstructor
@Tag(name = "业务异常服务")
@RestController
@RequestMapping(VarianConstant.FEIGN_PREFIX_PATH)
public class SysBizExceptionClient implements SysBizExceptionRemote {

    private final ISysBizExceptionService baseService;

    @Validated
    @Override
    @Operation(summary = "根据异常编码获取异常信息")
    @GetMapping(GET_MESSAGE_BY_CODE)
    public R<String> getMessageByCode(@NotBlank(message = "异常编码不能为空") @RequestParam("bizCode") String bizCode) {
        return R.data(baseService.getMessageByCode(bizCode));
    }
}
